package com.freesky.web.manager.controller;

import com.freesky.common.enums.RedisKeyEnum;
import com.freesky.common.pojo.UserLoginInfo;
import com.freesky.common.redis.IRedisTemplate;
import com.freesky.web.manager.service.ISystemInfoService;
import com.freesky.web.manager.shiro.CurrentUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author: 陈玉林
 * @modifiedBy:
 * @date: Create In 16:19 2019-01-09
 * @description:
 */
@Controller
public class WelcomeController {
    @Autowired
    private IRedisTemplate redisTemplate;
    @Autowired
    private ISystemInfoService systemInfoService;
    @GetMapping("/welcome/page")
    public String welcomePage(Model model) {
        String username = CurrentUser.INSTANCE.getUser().getUsername();
        UserLoginInfo userLoginInfo= redisTemplate.getCacheObject(RedisKeyEnum.USER_LOGIN_INFO_PREFIX.getKey()+"-"+username, UserLoginInfo.class);
        model.addAttribute("userLoginInfo", userLoginInfo);
        model.addAttribute("systemInfo", systemInfoService.getInfo());
        return "welcome";
    }
}
